

/**
 * 字符截取
 * @param str 
 * @param len 
 * @returns 
 */
export const cutstr = (str,len) => {
  var str_length = 0;
  var str_len = 0;
 var str_cut = '';
  str_len = str.length;
  for (var i = 0; i < str_len; i++) {
   let a = str.charAt(i);
    str_length++;
    if (encodeURI(a).length > 4) {
//中⽂字符的长度经编码之后⼤于4
      str_length++;
    }
    str_cut = str_cut.concat(a);
    if (str_length >= len) {
      str_cut = str_cut.concat("...");
      return str_cut;
    }
  }
//如果给定字符串⼩于指定长度，则返回源字符串；
  if (str_length < len) {
    return str;
  }
}
